package com.example.kuayu;

import org.springframework.web.bind.annotation.*;

/**
 *
 * Created by 95577 on 2018/6/29.
 */
@RestController
@RequestMapping("/test/")
@CrossOrigin // spring框架解决跨域
public class demoController {

    @GetMapping("get1")
    // @CrossOrigin
    private ResultBean get1() {
        System.out.println("demoController.get1");
        return new ResultBean("get1 ok");
    }

    @PostMapping("postJson")
    public ResultBean postJson(@RequestBody User user) {

        System.out.println("demoController.postJson");
        return new ResultBean("postJson " + user.getName());
    }

    @GetMapping("getcookie")
    public ResultBean getCookie(@CookieValue(value = "cookie1") String cookie) {
        System.out.println("demoController.getCookie");
        return new ResultBean("cookie1：" + cookie);
    }

    @GetMapping("getHeader")
    private ResultBean getHeader(@RequestHeader("x-header1") String header1, @RequestHeader("x-header2") String header2) {
        System.out.println("demoController.getHeader");
        return new ResultBean("getHeader：" + header1 + " " + header2);
    }
}
